// 1.引入vue
import vue from 'vue'
// 2.引入vue-router
import VueRouter from 'vue-router'

// 3.引入组件
import index from '@/components/17.主页.vue'
import pro from '@/components/18.产品.vue'
import computer from '@/components/computer.vue'
import mobai from '@/components/mobai.vue'
import erji from '@/components/erji.vue'

// 4.use：让vue使用vue-router进行路由管理
vue.use(VueRouter)

// 4.创建路由对象：实现路由和组件的映射
const router = new VueRouter({

  routes: [
    {
      // name: 'index',
      // path: '/',
      // redirect: { name: 'index' }
      name: 'index2',
      path: '/',
      // 当打开根组件的时候，让其自动的进行重定向--让其再映射下一个组件
      redirect: { name: 'index' }
    },
    {
      name: 'index',
      path: '/index',
      component: index

    },
    {
      name: 'pro',
      path: '/pro/:id',
      component: pro,
      children: [
        {
          name: 'computer',
          path: 'computer',
          component: computer

        },
        {
          name: 'mobai',
          path: 'mobai',
          component: mobai

        },
        {
          name: 'erji',
          path: 'erji',
          component: erji

        }

      ]

    }

  ]

})

export default router
